package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250124092442CreateRolesTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250124092442CreateRolesTable) Signature() string {
	return "20250124092442_create_roles_table"
}

// Up Run the migrations.
func (r *M20250124092442CreateRolesTable) Up() error {
	if !facades.Schema().HasTable("roles") {
		return facades.Schema().Create("roles", func(table schema.Blueprint) {
			table.ID()
			//table.Integer("tenant_id").Nullable().Default(0).Unsigned().Comment("租户id")
			table.String("role_name").Nullable().Comment("角色名")
			table.String("description", 255).Nullable().Comment("备注")
			table.Timestamps()
			table.SoftDeletes()

			table.Unique("role_name", "deleted_at")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250124092442CreateRolesTable) Down() error {
	return facades.Schema().DropIfExists("roles")
}
